from flask import Blueprint,request,g
from src.Service.Personservice import PersonService

PersonController = Blueprint('PersonController',__name__)
personservice = PersonService()

@PersonController.route("/login")
def index():
    phone = request.args.get('phone',type=str)
    return personservice.login(phone)

@PersonController.route("/getOrder")
def getOrder():
    userId = g.userId
    return personservice.getOrder(int(userId))

@PersonController.route("/updateOrder",methods=["GET","POST"])
def updateOrder():
    userId = g.userId
    props = request.json
    return personservice.updateOrder(int(userId),props.get("info"))

